home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!netnews
- From: billbo@ix.netcom.com (Bill Boland)
- Newsgroups: comp.os.ms-windows.programmer.tools.mfc,comp.lang.c++,comp.lang.basic.visual.misc
- Subject: Re: Prob calling VC++ 4.0 DLL from VB4 (32bit)
- Date: Tue, 20 Feb 1996 10:26:52 GMT
- Organization: Netcom
- Message-ID: <3129a180.11614278@nntp.ix.netcom.com>
- References: <4f7u8h$63q@fountain.mindlink.net>
- NNTP-Posting-Host: lbx-ca3-05.ix.netcom.com
- X-NETCOM-Date: Tue Feb 20 2:26:58 AM PST 1996
- X-Newsreader: Forte Agent .99d/32.182
-
- a09748@giant.mindlink.bc.ca (ESSA) wrote:
-
- >
- >Having a frustrating time trying to call a function in a DLL developed in
- >VC++ 4.0 from Visual Basic 4.0 (32bit). I'm getting VB error 49 (bad DLL
- >calling convention) from the following simple function ...
- >
- >In mydll.h
- >#define DllExport __declspec(dllexport)
- >extern "C" long DllExport TestLongParam(long lParam);
- >
- >In mydll.cpp
- >extern "C" long DllExport TestLongParam(long lParam)
- >{
- > TRACE("TestLongParam called with %ld\n", lParam);
- > return(1L);
- >}
- >
- >The Declare in VB is
- >Declare Function TestLongParam Lib "MYDLL.DLL" (ByVal lParam As Long) As Long
- >
- >When I call TestLongParam from VB, I get the TRACE output with the correct
- >value for the passed parameter, but on return, VB gives error 49.
- >
- >Can anyone sugesst what is wrong with the way I have declared the functions ?
- >I have played around with the __stdcall modifier, the WINAPI macro and even
- >tried the old obsolete FAR PASCAL with no success.
- >
- >
-
- I may have a clue since I had a similar situation today.
- If a DLL is compiled with VB 4.0 WITHOUT a module definition file and
- uses the new __declspec( dllexport ) to declare functions as
- exportable, VB4 cannot seem to understand them. At least that is what
- I discovered today on my own.
-
- I created a small DLL with a function that passes a long value and
- returned the long value. For example:
-
- #define DllExport __declspec( dllexport )
-
- DllExport DWORD Test( DWORD data );
-
- DWORD
- Test( DWORD data )
- {
- return data;
- }
-
- VB4 could not seem to handle this. Yet, if I went back to the
- traditional method (FAR PASCAL), used a module definition file and
- declared the function name in the EXPORTS section, I had no problem. I
- really don't know enough about VB4 or the __declspec( dllexport ) to
- know why this is...but as soon as I used an EXPORTS section and a
- module definition file, all my problems went away.
-
- I hope this helps. I know it's a stab in the dark but it sure did
- cause me grief and sounded close to the problem you have encountered.
-
- Good luck,
-
- Bill Boland
- --------
- billbo@ix.netcom.com
- Just a friendly little hobbit. Master of his domain.
-